<%--
  User: dw
  Date: 2019/12/9
  Time: 16:32
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>修改用户信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
</head>
<body>
<form class="layui-form" action="" id="updateUser">
    <div class="layui-form-item">
        <label class="layui-form-label">工号</label>
        <div class="layui-input-block">
            <input type="text" name="userId" required  lay-verify="required" autocomplete="off" class="layui-input" readonly >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="userName" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <select name="userGender" lay-filter="myselect">
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所属部门</label>
        <div class="layui-input-block">
            <select name="depId" lay-filter="myselect" id="dep">
                <option value="1">经理部</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-block">
            <input type="text" name="tel" required  lay-verify="phone" placeholder="联系电话" autocomplete="off" class="layui-input">
        </div>
    </div>
</form>

</body>
<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['layer','form','laydate'],function(){
        var layer = layui.layer;
        var laydate = layui.laydate;
        var  $ = layui.jquery;
        var form = layui.form;
        form.render();
        //文档加载时加载部门信息
        $(function () {
            //加载部门信息
            $.ajax({
                url: "/dep/loadAll",
                data:{},
                dataType:"json",
                type:"post",
                success:function (res) {
                    var depList = res;

                    var str = "";
                    for(var i = 0;i < depList.length; i++){
                        var dep = depList[i];
                        str += "<option value='"+dep.depId+"'>"+dep.depName+"</option>";
                    }
                    $("#dep").html(str);
                    //必须重新加载
                    form.render();
                },
                error:function (e) {
                    console.log(e.responseText)
                }
            });
        });
    });

    //窗体传值
    function child(data) {
        layui.use(['layer','form'],function() {
            var layer = layui.layer;
            var $ = layui.jquery;
            var form = layui.form;
            $("input[name= 'userId']").val(data.userId);
            $("input[name= 'userName']").val(data.userName);
            $("input[name= 'tel']").val(data.tel);
        });
    }


</script>
</html>
